﻿@using Coralcode.Base.Utils
@using CoralNode.MvcClient.Enums
@model CoralNode.Core.Entity.Domains.User.UserDomain
<div id="pbody" style="left: 0">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_setting_system"></span><span class="t t_c">帐号设置</span>
        </div>
        <div id="main">
            <div class="content_tab extra_normal">
                <div class="tablist extra_normal" data-js="tab">
                    <a href="#">修改密码</a>
                    @*<a href="#">自动登录</a>*@
                </div>
            </div>

            @if (@ViewBag.Msg != null) {
                <div class="error_msg">
                    @ViewBag.Msg.Msg
                </div>
            }
            <div class="pt_3 js_tabcnt">
                <div>
                    <form id="spform" action="/m/home/changepassword" method="post" enctype="multipart/form-data">
                        <div class="table_form form_main ">
                            <div class="pl_2 pb_3">
                                @Html.AntiForgeryToken()
                                @Html.ValidationSummary(true)
                                <table>
                                    <tbody>
                                        <tr>
                                            <th width="80">名称<span class="rq">*</span></th>
                                            <td>
                                                @(string.IsNullOrEmpty(Model.Name) ? Model.Account : Model.Name)
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>旧密码<span class="rq">*</span></th>
                                            <td>@Html.Password("OldPassword", string.Empty, new { @class = "text w_37" })
                                                <div class="exp ml_1">4-16个字符，支持英文小写、数字、下划线</div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>新密码<span class="rq">*</span></th>
                                            <td>@Html.Password("Password", string.Empty, new { @class = "text w_37" })
                                                <div class="exp ml_1">4-16个字符，支持英文小写、数字、下划线</div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>确认密码<span class="rq">*</span></th>
                                            <td>@Html.Password("ConPassword", string.Empty, new { @class = "text w_37" })
                                                <div class="exp ml_1">4-16个字符，支持英文小写、数字、下划线</div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="submitbox p_2 extra_normal">
                            <input type="submit" class="btn_1" value="提    交" />
                        </div>
                    </form>
                </div>
                <div class="table_form form_main ">
                    <form action="/m/home/SetAutoLogin" method="post" enctype="multipart/form-data" class="js_autologin">
                        <div class="pl_2 pb_3">
                            @Html.AntiForgeryToken()
                            @Html.ValidationSummary(true)
                            <table>
                                <tbody>
                                    <tr>
                                        <th width="80">自动登录：
                                        </th>
                                        <td>
                                            @foreach (var item in (Dictionary<string, object>)EnumUtil.GetDescriptionValues(ClientEnums.AutoLoginType)) {
                                                <label class="mr_2">
                                                    <input type="radio" value="@item.Value" name="autoType" class="mt_0-5 mr_0-5" @((int)ViewBag.AutoType == (int)item.Value ? "checked=checked" : string.Empty) />@item.Key
                                                </label>
                                            }
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $("form").submit(function (e) {
            e.preventDefault();
            var $this = $(this);
            if ($this.valid()) {
                $.post($this.attr("action"), $this.serialize(), function (data) {
                    if (data.Type == 5) {
                        $.alert(data.Msg);
                        setTimeout('location.href = "/m/"', 2000);
                    } else {
                        $.alert(data.Msg, "error");
                    }
                });
            }
        });

        $(".js_autologin").find("input[name='autoType']").click(function () {
            $(this).parents("form").submit();
        });
    })
</script>
